fix: cap the length of a string handed to the parsers CVE-2026-60075 - #55
Open
robrwo wants to merge 1 commit into
Open
fix: cap the length of a string handed to the parsers CVE-2026-60075#55robrwo wants to merge 1 commit into
robrwo wants to merge 1 commit into
Conversation
_parse_time removes a time from anywhere in the string with the
unanchored substitution s/$timerx/ /, where $timerx is an auto-generated
alternation of time patterns reached through a leading (?:$atrx|^|\s+).
The engine retries the match at every position of an interior whitespace
run: at each start position the leading \s+ consumes the rest of the run
greedily, the time alternation fails because the run holds no digits,
and the engine backtracks a space at a time across the run before
advancing the start position. The cost is quadratic in the length of
the run, and no time need be present in the string. On the machine this
patch was tested on, parsing "x" . (" " x 2000) . "x" took 1.7 seconds
of CPU and "x" . (" " x 16000) . "x" took 107 seconds, rising about
fourfold for each doubling of the run.
This fix rejects a string longer than a configurable $MAXLENGTH (256) at
the parse and parse_time entries, before any regex runs. Legitimate
date strings are well under 100 characters, and a 42 entry corpus of
legitimate formats parses to the same value before and after.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
_parse_time removes a time from anywhere in the string with the unanchored substitution s/$timerx/ /, where $timerx is an auto-generated alternation of time patterns reached through a leading (?:$atrx|^|\s+). The engine retries the match at every position of an interior whitespace run: at each start position the leading \s+ consumes the rest of the run greedily, the time alternation fails because the run holds no digits, and the engine backtracks a space at a time across the run before advancing the start position. The cost is quadratic in the length of the run, and no time need be present in the string. On the machine this patch was tested on, parsing "x" . (" " x 2000) . "x" took 1.7 seconds of CPU and "x" . (" " x 16000) . "x" took 107 seconds, rising about fourfold for each doubling of the run.
This fix rejects a string longer than a configurable $MAXLENGTH (256) at the parse and parse_time entries, before any regex runs. Legitimate date strings are well under 100 characters, and a 42 entry corpus of legitimate formats parses to the same value before and after.